2024/01/19 15:46
This vignette is described as a sample output using
hubVis package, one of the applications of Hubverse. By
using it the model projections(with quantile data) will be plotted.
For more information about the Hubverse standard format, please refer to the HubDocs website.
Plots are generated by applying:
The two data sets will be used as an example:
model output for a round associated with the origin date will be
concatenated, target: “incident case”, for the US national level, from
the example-complex-scenario-hub.
The data set also does not contain an ensemble calculated by applying
the function for example:
hubEnsembles::simple_ensemble(df_round1, agg_fun = "median")
rsvnet_hospitalization.csv: example of target data
which comes from the rsv-scenario-modeling-hub
repo
The model output data in the projection_data object
follows the structure of the
model_out_tbl class. This dataset is converted to a
model_out_tbl object after being read-in above. In addition
to the standard requirements for this class, the
plot_step_ahead_model_output() function in
hubVis requires that the dataset have a column whose value
corresponds to the variable that should be used for the x-axis of a
“step ahead” plot. In general, this should be a date variable that
corresponds to the date which is the “target” of a particular
prediction. By default it will look for the "target_date"
column, although this could be over-ridden by specifying a different
column using the x_col_name argument. In our example data,
this column does not exist, so we add it below:
#> # A tibble: 6 × 10
#> model_id origin_date target horizon location age_group target_date output_type
#> <chr> <date> <chr> <int> <chr> <chr> <date> <chr>
#> 1 team-mo… 2023-11-26 inc h… 1 US 0-0.99 2023-12-02 quantile
#> 2 team-mo… 2023-11-26 inc h… 1 US 0-0.99 2023-12-02 quantile
#> 3 team-mo… 2023-11-26 inc h… 1 US 0-0.99 2023-12-02 quantile
#> 4 team-mo… 2023-11-26 inc h… 1 US 0-0.99 2023-12-02 quantile
#> 5 team-mo… 2023-11-26 inc h… 1 US 0-0.99 2023-12-02 quantile
#> 6 team-mo… 2023-11-26 inc h… 1 US 0-0.99 2023-12-02 quantile
#> # ℹ 2 more variables: output_type_id <dbl>, value <dbl>
#> # A tibble: 6 × 6
#> location date age_group target value population
#> <chr> <date> <chr> <chr> <dbl> <dbl>
#> 1 47 2016-10-08 18-130 rate hosp 0.2 5126526
#> 2 47 2016-10-08 18-130 inc hosp 10.3 5126526
#> 3 41 2016-10-08 65-130 rate hosp 0.4 681767
#> 4 41 2016-10-08 65-130 inc hosp 2.73 681767
#> 5 27 2016-10-08 18-49 rate hosp 0 2280031
#> 6 27 2016-10-08 18-49 inc hosp 0 2280031
The projection_data and truth_data contain
information for multiple locations, and scenarios.
To plot the model projections for the US, No Scenario id :
##{r plot_us_facet_byagegroup, fig.height=32, include=FALSE} #projection_data <- dplyr::filter(projection_data_all, location ==default_location, target == default_target, # #model_id == default_model # ) #projection_data$age_group <- as.character(projection_data$age_group) # #truth_data <- dplyr::filter(truth_data_all, location == default_location, target == default_target, # time_idx < min(projection_data$target_date) , # time_idx > "2023-08-01") #truth_data$age_group <- as.character(truth_data$age_group) #plot_step_ahead_model_output(projection_data, truth_data, # use_median_as_point = TRUE, # facet = "age_group", facet_scales = "free_x", # facet_nrow = 7,facet_ncol = 2, facet_title = "top left", show_legend = TRUE) #
Multiple layout update are possible:
Change palette color and behavior:
It is possible to use only blues for all models, by setting the
pal_color parameter to NULL. This might be
especially useful when used for many models in conjunction with
highlighting the ensemble forecast using the ens_name and
ens_color argument.
The default blue color can be changed with the one_color
parameter
The input data frames can have different column names for the date
information. In this case, the two x_col_name and
x_truth_col_name parameters can be used to indicate the
variables that should be mapped to the x-axis.